home *** CD-ROM | disk | FTP | other *** search
- package java.awt;
-
- import java.awt.peer.PopupMenuPeer;
-
- public class PopupMenu extends Menu {
- private static final String base = "popup";
- static int nameCounter;
- private static final long serialVersionUID = -4620452533522760060L;
-
- public PopupMenu() {
- this("");
- }
-
- public PopupMenu(String label) {
- super(label);
- super.name = "popup" + nameCounter++;
- }
-
- public void addNotify() {
- synchronized(((MenuComponent)this).getTreeLock()){}
-
- try {
- if (super.peer == null) {
- super.peer = Toolkit.getDefaultToolkit().createPopupMenu(this);
- }
-
- int nitems = ((Menu)this).getItemCount();
-
- for(int i = 0; i < nitems; ++i) {
- MenuItem mi = ((Menu)this).getItem(i);
- mi.parent = this;
- mi.addNotify();
- }
- } catch (Throwable var6) {
- throw var6;
- }
-
- }
-
- public void show(Component origin, int x, int y) {
- Component p = (Component)super.parent;
- if (p == null) {
- throw new NullPointerException("parent is null");
- } else if (p != origin && p instanceof Container && !((Container)p).isAncestorOf(origin)) {
- throw new IllegalArgumentException("origin not in parent's hierarchy");
- } else if (p.getPeer() != null && p.isShowing()) {
- if (super.peer == null) {
- this.addNotify();
- }
-
- ((PopupMenuPeer)super.peer).show(new Event(origin, 0L, 501, x, y, 0, 0));
- } else {
- throw new RuntimeException("parent not showing on screen");
- }
- }
- }
-